﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text;
using IDAL.RF.SourceCategory;
using Model.RF.SourceCategory;

namespace DAL.RF.SourceCategory
{
    public class VSWRCheckItem : BaseRepository<VSWRCheckItemInfo>, IVSWRCheckItem
    {
        #region 静态字段部分
        private const string PARM_VSWRCHECKITEM_PRODUCTSN = "@ProductSN";
        private const string PARM_VSWRCHECKITEM_RECORDTIME = "@RecordTime";
        #endregion


        #region 检索部分
        public IList<VSWRCheckItemInfo> GetVSWRCheckItembySNDT(string productSN, DateTime recordTime)
        {
            SqlParameter[] parms = GetSNDTParameters();
            parms[0].Value = productSN;
            parms[1].Value = recordTime;
            return ExcuteSqlToGetEntities("VSWRCheckItem_selectbySNDT", parms);
        }
        #endregion

        #region 参数部分
        private static SqlParameter[] GetSNDTParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
					new SqlParameter(PARM_VSWRCHECKITEM_PRODUCTSN, SqlDbType.NVarChar, 50),
					new SqlParameter(PARM_VSWRCHECKITEM_RECORDTIME, SqlDbType.DateTime, 8)
                };
            return parms;
        }
        #endregion

        #region 重新基类部分
        public override VSWRCheckItemInfo GetEntityRecord(SqlDataReader rdr)
        {
            VSWRCheckItemInfo pro = new VSWRCheckItemInfo
            {
                ProductSN = rdr.GetValue(0).ToString(),
                RecordTime = rdr.GetDateTime(1),
                TestItemName = rdr.GetValue(2).ToString(),
                TestItemType = rdr.GetValue(3).ToString(),
                Spec = rdr.GetValue(4).ToString(),
                Result = rdr.GetValue(5).ToString(),
                IsPass = rdr.GetBoolean(6)
            };
            return pro;
        }
        #endregion
    }
}
